﻿using LayoutGridview.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.Xaml.Media;

namespace LayoutGridview.Helpers
{
    public static class SampleData
    {
        private static IEnumerable<SimpleData> s_GenerateSampleItems =
            typeof(Windows.UI.Colors)
                .GetRuntimeProperties()
                .Select(c => (Windows.UI.Color)c.GetValue(null))
                .OrderBy(c => ColorHelper.GetHue(c.R, c.G, c.B))
                .Select((c, i) => new SimpleData { Color = c, Index = i });
        public static IEnumerable<SimpleData> GenerateSampleItems()
        {
            return s_GenerateSampleItems;
        }

        public static IEnumerable<GroupData> GenerateSampleGroups()
        {
            var _Data = GenerateSampleItems();

            // since colors do not have a natural grouping, create one
            var _Red = new GroupData("Mostly Red", _Data.Where(x => x.Color.R > 200)) { Brush = new SolidColorBrush(Colors.Red) };
            var _Green = new GroupData("Mostly Green", _Data.Where(x => x.Color.G > 200)) { Brush = new SolidColorBrush(Colors.Green) };
            var _Blue = new GroupData("Mostly Blue", _Data.Where(x => x.Color.B > 200)) { Brush = new SolidColorBrush(Colors.Blue) };

            return new[] { _Red, _Green, _Blue };
        }

    }
}
